<template>
	<view>
		<u-sticky>
			<view class="mainpadding_top ffffff flexbetween">
				<view class="titletext bold hei_text">商品名稱</view>
				<input class="main_size bold xiaolan textright" type="text" style="width: 80%;" disabled
					placeholder="請輸入商品名稱" v-model="name">
				<!-- <view class="main_size bold hei_text">{{goodsInfo.name}}</view> -->
			</view>
		</u-sticky>
		<view class="mainpadding_top ffffff">
			<view class="titletext bold hei_text">商品主圖（{{logoimage_arr.length}}/1）</view>
			<view class="flexleft flex_wrap">
				<view class="itemimgBox flexcenter margin_top2" v-for="(item,index) in logoimage_arr" :key="index">
					<!-- 已上传 -->
					<view class="listleftimg radius">
						<image class="radius" :src="item" mode=""></image>
						<view class="deleteimg" @click="deleimage(index,logoimage,logoimage_arr)"></view>
					</view>
				</view>
				<view class="itemimgBox flexcenter margin_top2" @click="uploadImgtop(logoimage,logoimage_arr,1)"
					v-if="logoimage_arr.length<1"><!-- 未上传 -->
					<image class="listleftimg radius" src="@/static/image/system/upimg.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="titletext bold hei_text">商品輪播圖（{{carouselimages_arr.length}}/10）</view>
			<view class="flexleft flex_wrap">
				<view class="itemimgBox flexcenter margin_top2" v-for="(item,index) in carouselimages_arr" :key="index">
					<!-- 已上传 -->
					<view class="listleftimg radius">
						<image class="radius" :src="item" mode=""></image>
						<view class="deleteimg" @click="deleimage(index,carouselimages,carouselimages_arr)"></view>
					</view>
				</view>
				<view class="itemimgBox flexcenter margin_top2" @click="uploadImg(carouselimages,carouselimages_arr,10)"
					v-if="carouselimages_arr.length<10"><!-- 未上传 -->
					<image class="listleftimg radius" src="@/static/image/system/upimg.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="titletext bold hei_text">商品詳情圖（{{detailsimages_arr.length}}/5）</view>
			<view class="flexleft flex_wrap">
				<view class="itemimgBox flexcenter margin_top2" v-for="(item,index) in detailsimages_arr" :key="index">
					<!-- 已上传 -->
					<view class="listleftimg radius">
						<image class="radius" :src="item" mode=""></image>
						<view class="deleteimg" @click="deleimage(index,detailsimages,detailsimages_arr)"></view>
					</view>
				</view>
				<view class="itemimgBox flexcenter margin_top2" @click="uploadImg(detailsimages,detailsimages_arr,5)"
					v-if="detailsimages_arr.length<5"><!-- 未上传 -->
					<image class="listleftimg radius" src="@/static/image/system/upimg.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="flexbetween">
				<view class="titletext bold hei_text">上傳影片</view>
				<view class="flexright" @click="delevideo()" v-if="mvfile_arr">
					<text class="xiaohong">刪除影片</text>
				</view>
			</view>
			<view class="flexleft flex_wrap">
				<view class="itemimgBox flexcenter margin_top2" v-if="mvfile_arr">
					<!-- 已上传 -->
					<view class="listleftimg radius">
						<video class="radius" :src="mvfile_arr" style="width: 160rpx;height: 160rpx;"></video>
					</view>
				</view>
				<view class="itemimgBox flexcenter margin_top2" @click="upvideo()" v-if="!mvfile_arr"><!-- 未上传 -->
					<image class="listleftimg radius" src="@/static/image/system/upvideo.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="titletext bold hei_text">商品描述</view>
			<textarea placeholder="請輸入內容" maxlength="-1" class="main_size margin_top bold hei_text"
				style="height: 150rpx;width: 100%;" v-model="des" />
		</view>
		<view class="mainpadding_top ffffff flexbetween" @click="jumpurl('/pages/workbench/yanseb')">
			<view class="titletext bold hei_text">顔色</view>
			<view class="flexright">
				<view class="radius margin_right1" v-show="font_color" style="width: 50rpx;height: 50rpx;" :style="[{ backgroundColor: font_color }]"></view>
				<view class="main_size bold hei_text margin_right1">{{font_color}}</view>
					<u-icon name="arrow-right" color="#333" size="16"></u-icon>
			</view>
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">是否上架</view>
			<u-radio-group v-model="is_grounding" placement="row" circle>
				<u-radio activeColor="#feb800" :customStyle="{marginRight: '30rpx'}" label="是" name="1"></u-radio>
				<u-radio activeColor="#feb800" label="否" name="0"></u-radio>
			</u-radio-group>
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">是否主商品</view>
			<u-radio-group v-model="is_main" placement="row" circle>
				<u-radio activeColor="#feb800" :customStyle="{marginRight: '30rpx'}" label="是" name="1"></u-radio>
				<u-radio activeColor="#feb800" label="否" name="0"></u-radio>
			</u-radio-group>
		</view>
		<view class="mainpadding_top ffffff flexbetween" v-if="shopInfo.hy_type==1">
			<view class="flexleft">
				<view class="titletext bold hei_text">選擇計時套餐</view>
				<view class="" @click="cdbtc_ids=''">
					<u-icon name="trash" color="#ff0000" size="16"></u-icon>
				</view>
			</view>
			<view class="flexright" @click="jumpdetail('/pages/workbench/chidaob?type=1&cdbtc_ids=',cdbtc_ids)">
				<input class="main_size bold hei_text textright" type="text" placeholder="請選擇計時套餐" disabled
					v-if="!cdbtc_ids">
				<view class="main_size bold hei_text textright" v-else>已選擇</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="titletext bold hei_text">國際條碼</view>
			<u--input placeholder="請輸入編碼" style="border-color: #feb800 !important;"
				class="margin_top main_size bold hei_text" v-model="barcode">
				<u-icon name="scan" slot="suffix" color="#feb800" size="28" @click="saoma()"></u-icon>
			</u--input>
		</view>
		<view class="lineorange"></view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">稅金</view>
			<u-radio-group v-model="rj_type" placement="row" circle>
				<u-radio activeColor="#feb800" :customStyle="{marginRight: '30rpx'}" label="應稅" :name="1"></u-radio>
				<u-radio activeColor="#feb800" :customStyle="{marginRight: '30rpx'}" label="零稅" :name="2"></u-radio>
				<u-radio activeColor="#feb800" label="免稅" :name="3"></u-radio>
			</u-radio-group>
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">用量單位</view>
			<input class="main_size bold hei_text textright" type="text" placeholder="請輸入用量單位" v-model="unit">
		</view>
		<view class="flexbetween ffffff mainpadding_top" v-if="shopInfo.hy_type==0">
			<view class="titletext bold hei_text">重量計價</view>
			<u-switch inactiveColor="rgb(230, 230, 230)" v-model="weight_jj_statusFlag" activeColor="#feb800"
				@change="weightjjstatusFlagchange"></u-switch>
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">計價方式</view>
			<u-radio-group v-model="jjfs" placement="row" circle>
				<u-radio activeColor="#feb800" :customStyle="{marginRight: '30rpx'}" label="買賣" :name="0"></u-radio>
				<u-radio activeColor="#feb800" label="多重計價" :name="1"></u-radio>
			</u-radio-group>
		</view>
		<view class="mainpadding_top ffffff flexbetween" v-if="jjfs==0">
			<view class="titletext bold hei_text">商品價格</view>
			<input class="main_size bold hei_text textright" type="number" placeholder="請輸入" v-model="price">
		</view>
		<view class="mainpadding_top ffffff flexbetween" v-if="jjfs==1">
			<view class="titletext bold hei_text">處理選擇</view>
			<u-radio-group v-model="is_cl" placement="row" circle>
				<u-radio activeColor="#feb800" :customStyle="{marginRight: '30rpx'}" label="計算" :name="0"></u-radio>
				<u-radio activeColor="#feb800" label="選擇" :name="1"></u-radio>
			</u-radio-group>
		</view>
		<!-- <view class="mainpadding_top ffffff flexbetween" v-if="is_cl==1 && jjfs==1">
			<view class="titletext bold hei_text">级距單位</view>
			<input class="main_size bold hei_text textright" type="text" placeholder="請输入單位" v-model="jj_unit">
		</view> -->
		<!-- 销售类别 -->
		<view class="mainpadding_top ffffff" v-if="jjfs==1">
			<view class="flexbetween">
				<view class="titletext bold hei_text">銷售類別</view>
				<view class="addimg" @click="addSale"></view>
				<!-- <view class="" @click="addSale">
					<u-icon name="plus-circle-fill" color="#ff7424" size="28"></u-icon>
				</view> -->
			</view>
			<view class="bghui radius mainpadding_top" v-for="(item,index) in saleList" :key="index">
				<view class="flexbetween">
					<view class="main_size hei_text bold">名稱</view>
					<input class="main_size hei_text bold textright" type="text" placeholder="請輸入名稱"
						v-model="item.name">
				</view>
				<!-- <view class="flexbetween margin_top">
					<view class="main_size hui_text bold">單价</view>
					<input class="main_size hui_text bold textright" type="number" placeholder="請输入單价"
						v-model="item.price">
				</view> -->
				<view class="flexbetween margin_top">
					<view class="main_size hei_text bold">基本價</view>
					<input class="main_size hei_text bold textright" type="number" placeholder="請輸入基本價"
						v-model="item.price_j">
				</view>
				<view class="flexbetween margin_top">
					<view class="main_size hei_text bold">多重單價</view>
					<view class="flexleft">
						<input class="main_size hong_text bold textright borderhui"
							style="max-width: 180rpx; height: 80rpx;" type="number" placeholder="計算值"
							v-model="item.jsval" @confirm="pushmore(item)">
						<input class="main_size hong_text bold textright borderhui"
							style="max-width: 180rpx; height: 80rpx;" type="number" placeholder="單價"
							@confirm="pushmore(item)" v-model="item.moremoney">
						<view class="" @click="pushmore(item)">
							<u-icon name="plus-circle-fill" color="#ff7424" size="28"></u-icon>
						</view>
					</view>
				</view>
				<view class="flexbetween ffffff radius margin_top2" style="padding: 20rpx;"
					v-for="(ite,ind) in item.morepice" :key="ind+'more'">
					<view class="flexleft ">
						<view class="main_size hei_text bold" style="margin-right: 80rpx;">計算值：<text
								class="xiaohong main_size">{{ite.val}}</text></view>
						<view class="main_size hei_text bold">單價：<text class="xiaohong main_size">{{ite.money}}</text>
						</view>
					</view>
					<view class="" @click="item.morepice.splice(ind,1)">
						<u-icon name="trash" color="#ff0000" size="16"></u-icon>
					</view>
				</view>
				<view class="flexright margin_top" @click="delSale(item,index)">
					<u-icon name="trash" color="#333" size="16"></u-icon>
					<view class="xiaohei">刪除</view>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff flexbetween" v-if="shopInfo.hy_type==5"
			@click="selectRule('/pages/workbench/jisuanfs?selectType=1')">
			<view class="titletext bold hei_text">選擇公式</view>
			<view class="flexright">
				<input class="main_size bold hei_text textright" type="text" placeholder="請選擇公式" disabled
					v-model="shopformula_name">
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="flexbetween ffffff mainpadding" v-if="shopInfo.hy_type==5">
			<view class="titletext bold hei_text">尺寸開關</view>
			<u-switch inactiveColor="rgb(230, 230, 230)" v-model="is_sizeFlag" activeColor="#feb800"
				@change="sizeFlagchange"></u-switch>
		</view>
		<view class="mainpadding_top ffffff flexbetween" v-if="shopInfo.hy_type==5">
			<view class="titletext bold hei_text">檔案上傅</view>
			<u-radio-group v-model="is_up" placement="row" circle>
				<u-radio activeColor="#feb800" :customStyle="{marginRight: '30rpx'}" label="是" name="1"></u-radio>
				<u-radio activeColor="#feb800" label="否" name="0"></u-radio>
			</u-radio-group>
		</view>
		<view class="mainpadding_top ffffff" v-if="shopInfo.hy_type==5">
			<view class="flexbetween">
				<view class="titletext bold hei_text">基本尺寸</view>
				<view class="flexright">
					<input class="main_size bold hei_text textright margin_right" type="number" placeholder="請輸入基本尺寸"
						v-model="size_text" @confirm="addSize">
					<view class="addimg" @click="addSize"></view>
				</view>
			</view>
			<view class="flexleft flex_wrap">
				<view class="flexcenter margin_top margin_right"
					style="padding: 5px 15rpx;text-align: center; min-width: 100rpx; border-radius: 50rpx;border: 1rpx solid #ff0000;"
					v-for="(item,index) in size" :key="index">
					<text class="margin_right">{{item}}</text>
					<view class="" @click="size.splice(index,1)">
						<u-icon name="close-circle-fill" color="#ff0000" size="20"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">基本數量</view>
			<input class="main_size bold hei_text textright" type="number" placeholder="請輸入基本數量" v-model="num">
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">基本用量</view>
			<input class="main_size bold hei_text textright" type="text" placeholder="請輸入用量" v-model="cai">
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">交貨天數</view>
			<input class="main_size bold hei_text textright" type="number" placeholder="請輸入天數" v-model="day">
		</view>
		<view class="lineorange"></view>
		<view class="mainpadding ffffff">
			<view class="flexbetween">
				<view class="flexleft">
					<view class="titletext bold hei_text">工作站</view>
					<view class="" @click="shopwork_id='';shopwork_name='';gzzList=[]">
						<u-icon name="trash" color="#ff0000" size="20"></u-icon>
					</view>
				</view>
				<view class="flexright" @click="selectgzz()">
					<!-- <input class="main_size bold hei_text textright" type="text" placeholder="請選擇工作站" disabled
						v-model="shopwork_name"> -->
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
			</view>
			<view style="padding: 0 10rpx;">
				<view class="margin_top1 flexbetween" v-for="item in gzzList" :key="item.id">
					<view class="main_size hei_text">{{item.name}}</view>
					<view class="huang_text main_size">{{item.tbzz}}
					<text v-show="item.tbzz && item.zd_status==1">/</text><text v-show="item.zd_status==1">轉</text></view>
				</view>
			</view>
		</view>
		<view class="lineorange"></view>
		<view class="mainpadding ffffff flexbetween">
			<view class="flexleft">
				<view class="titletext bold hei_text">原物料</view>
				<view class="">
					<u-icon name="trash" color="#ff0000" size="20"></u-icon>
				</view>
			</view>
			<view class="flexright">
				<input class="main_size bold hei_text textright" type="text" placeholder="請選擇原物料" disabled>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="lineorange"></view>
		<view class="mainpadding ffffff flexbetween" v-if="shopInfo.hy_type==5">
			<view class="flexleft">
				<view class="titletext bold hei_text">產品規格1</view>
				<view class="" @click="sku_id=[]">
					<u-icon name="trash" color="#ff0000" size="20"></u-icon>
				</view>
			</view>
			<view class="flexright" @click="selectRule(`/pages/workbench/shangpinggy?id=${goodsId}`)">
				<input class="main_size bold hei_text textright" type="text" placeholder="請選擇產品規格1" disabled
					v-if="!sku_id.length">
				<view class="main_size bold hei_text textright" v-else>已選擇</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="mainpadding_top ffffff flexbetween" v-if="shopInfo.hy_type!=6">
			<view class="flexleft">
				<view class="titletext bold hei_text">產品規格2</view>
				<view class="" @click="spu_id=[]">
					<u-icon name="trash" color="#ff0000" size="20"></u-icon>
				</view>
			</view>
			<view class="flexright" @click="selectRule(`/pages/workbench/shangpingge?id=${goodsId}`)">
				<input class="main_size bold hei_text textright" type="text" placeholder="請選擇產品規格2" disabled
					v-if="!spu_id.length">
				<view class="main_size bold hei_text textright" v-else>已選擇</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="flexbetween">
				<view class="titletext bold hei_text">客戶資料填寫</view>
				<view class="flexright">
					<input class="main_size bold hei_text textright margin_right" type="text" placeholder="請輸入"
						v-model="by_text" @confirm="addby">
					<view class="addimg" @click="addby"></view>
				</view>
			</view>
			<view class="flexleft flex_wrap">
				<view class="flexcenter margin_top margin_right"
					style="padding: 5px 15rpx;text-align: center; min-width: 100rpx; border-radius: 50rpx;border: 1rpx solid #ff0000;"
					v-for="(item,index) in sp_attr" :key="index">
					<text class="margin_right">{{item}}</text>
					<view class="" @click="sp_attr.splice(index,1)">
						<u-icon name="close-circle-fill" color="#ff0000" size="20"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<view class="lineorange"></view>
		<view class="mainpadding ffffff flexbetween">
			<view class="titletext bold hei_text">選擇廠商</view>
			<view class="flexright" @click="selectRule('/pages/workbench/xuanzecs?type=1')">
				<input class="main_size bold hei_text textright" type="text" placeholder="請選擇廠商" disabled
					v-if="!firm_id">
				<view class="main_size bold hei_text textright" v-else>已選擇</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">廠商電話</view>
			<input class="main_size bold hei_text textright" type="number" placeholder="請輸入廠商電話" v-model="phone">
		</view>
		<view class="lineorange"></view>
		<view class="mainpadding ffffff flexbetween">
			<view class="titletext bold hei_text">配送商品重量</view>
			<input class="main_size bold hei_text textright" type="text" placeholder="請输入重量" v-model="weight">
		</view>
		<view class="mainpadding_top ffffff flexbetween">
			<view class="titletext bold hei_text">商品才積</view>
			<input class="main_size bold hei_text textright" type="text" placeholder="請輸入才積" v-model="caiamass">
		</view>
		<view class="lineorange"></view>
		<view class="mainpadding ffffff flexbetween">
			<view class="titletext bold hei_text">上架時間</view>
			<view class="flexright" @click="selectRuledate('/pages/workbench/tianjiarq')">
				<input class="main_size bold hei_text" v-if="date==''" type="text" placeholder="請選擇" disabled=""
					style="text-align: right;">
				<view class="main_size bold hei_text textright" v-else>已選擇</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="lineorange"></view>
		<view class="mainpadding ffffff flexbetween">
			<view class="titletext bold hei_text">商品庫存</view>
			<input class="main_size bold hei_text textright" type="text" placeholder="數量為-1時不限庫存" v-model="end_num">
		</view>
		<view class="mainpadding ffffff flexbetween">
			<view class="titletext bold hei_text">商品限點數量</view>
			<input class="main_size bold hei_text textright" type="text" placeholder="數量為-1時不限" v-model="xd_num">
		</view>
		<view class="mainpadding_top ffffff">
			<view class="flexbetween">
				<view class="titletext bold hei_text">出貨須知</view>
				<view class="flexright" @click="jumpurl('/pages/workbench/chuhuoxzfl?type=1')">
					<view class="xiaohui main_size">導入</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
			</view>
			<textarea placeholder="請輸入內容" maxlength="-1" class="main_size margin_top bold hei_text"
				style="height: 150rpx;width: 100%;" v-model="notice" />
		</view>
		<view class="mainpadding_top ffffff">
			<view class="flexbetween">
				<view class="titletext bold hei_text">商品購買須知</view>
				<view class="flexright" @click="jumpurl('/pages/workbench/goumaixzfl?type=1')">
					<view class="xiaohui main_size">導入</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
			</view>
			<textarea placeholder="請輸入內容" maxlength="-1" class="main_size margin_top bold hei_text"
				style="height: 150rpx;width: 100%;" v-model="buy_notice" />
		</view>
		<view class="mainpadding">
			<view class="submitbtn" @click="confirm">確認</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				goodsId: "", //商品id
				goodsInfo: "", //商品详情

				name: "", //商品名称
				logoimage: [], //商品主图
				logoimage_arr: [], //商品主图展示
				carouselimages: [], //商品轮播图
				carouselimages_arr: [], //商品轮播图展示
				detailsimages: [], //商品详情图
				detailsimages_arr: [], //商品详情图展示
				mvfile: "", //商品影片
				mvfile_arr: "", //商品影片展示
				saleList: [
					// 	{
					// 	id: "", //销售类别id
					// 	name: "", //名称
					// 	jsval: "",
					// 	moremoney: "",
					// 	morepice: [],
					// 	price_j: "", //基本价
					// },
				], //销售类别列表
				saleId: [], //销售类别id
				day: "", //交货天数
				num: "", //基本数量
				cai: "", //基本用量
				des: "", //商品描述
				font_color:"",
				size: [], //基本尺寸
				unit: "", //單位
				jj_unit: "", //级距單位
				weight: "", //重量
				caiamass: "", //才积

				shopformula_id: "", //公式ID
				shopformula_name: "",
				shopwork_id: "", //工作站ID
				shopwork_name: "",
				gzzList:[],
				spu_id: [], //商品规格1id
				sku_id: [], //商品规格2id
				cdbtc_ids: "", //計時套餐id
				price: "", //价格
				firm_id: "", //廠商ID
				phone: "", //廠商电话
				barcode: "", //条形碼
				if_upFlag: 0,
				is_cl: 0, //0計算，1選擇
				jjfs: 0, //0，商品价格，1多重計价
				is_up: "1", //档案是否上传:0=否,1=是
				rj_type: 1, // 1=应税  2=零税  3=免税
				if_groundingFlag: 0,
				is_grounding: "0", //是否上架:0=否,1=是
				is_main: "0",
				hy_type: 0, //行业类型:0=无,1=吃到饱,2=诊所,3=住宿,4=租借,5工程，6超商
				date: "", //上架時間
				datedeail: [],
				// enddate: "", //下架時間
				is_sizeFlag: false,
				is_size: 0, //尺寸开关:0=否,1=是
				weight_jj_statusFlag: false,
				weight_jj_status: 0,
				end_num: "", //库存
				xd_num: "",
				notice: "", //出货須知
				buy_notice: "", //購買須知
				shop_id: uni.getStorageSync("shop_id"),
				// count: "", //销量
				size_text: "",
				isdetail: 0,
				shopInfo: {},
				by_text: "",
				sp_attr: [], //商品 客戶資料填寫
			}
		},
		watch: {
			jjfs(val) {
				if (this.isdetail == 1) {
					if (val == 0) {
						this.jj_unit = ""
						this.saleList = []
					} else {
						this.price = ""

					}
				}

			}
		},
		onLoad(options) {
			if (options.id) {
				this.listid = options.id
				uni.setNavigationBarTitle({
					title: "編輯電影"
				})
			}
			if (options.goodsId) {
				this.goodsId = options.goodsId
				this.getGoodsInfo()
			}

			uni.$on("checkcdbtc", data => {
				this.cdbtc_ids = data
				console.log(data, "選擇的計時套餐");
			})
			uni.$on("selectSku", data => {
				this.sku_id = data
				console.log(data, "選擇的規格1");
			})
			uni.$on("selectSpu", data => {
				this.spu_id = data
				console.log(data, "選擇的規格2");
			})
			uni.$on("selectShop", data => {
				this.firm_id = data
				console.log(data, "選擇的廠商");
			})
			uni.$on("selectWorkId", data => {
				this.gzzList = data
				let shopwork_id = []
				let shopwork_name = []
				data.forEach(item=>{
					shopwork_id.push(item.id)
					shopwork_name.push(item.name)
				})
				this.shopwork_id = shopwork_id.join()
				this.shopwork_name = shopwork_name.join()
			})
			uni.$on("selectFormula", data => {
				this.shopformula_id = data.id
				this.shopformula_name = data.name
				console.log(data, "選擇的計算管道");
			})
			uni.$on("ywmcode", data => {
				this.barcode = data
				console.log(data, "國際條碼掃描");
			})
			uni.$on("selecttimefn", data => {
				this.datedeail = data.datedeail
				this.date = data.date
				console.log(data, "選擇上架時間");
			})
			uni.$on("checkchzx", data => {
				this.notice = data
				console.log(data, "選擇出貨須知");
			})
			uni.$on("checkgmzx", data => {
				this.buy_notice = data
				console.log(data, "選擇購買須知");
			})
			uni.$on("checkColor", data => {
				this.font_color = data
				console.log(data, "選擇顔色");
			})
			this.getshopDetail()
		},
		onUnload() {
			uni.$off("checkgmzx")
			uni.$off("checkchzx")
			uni.$off("selectSku")
			uni.$off("selectSpu")
			uni.$off("selecttimefn")
			uni.$off("ywmcode")
			uni.$off("selectFormula")
			uni.$off("selectWorkId")
			uni.$off("selectShop")
			uni.$off("checkcdbtc")
			uni.$off("checkColor")
		},
		methods: {
			addspu() {
				uni.navigateTo({
					url: "/pages/workbench/shangpingge?type=2&msg=" + encodeURIComponent(JSON.stringify(this
						.spu_data))
				})
			},
			selectgzz() {
				let data = {
					type:1,
					gzzList:this.gzzList,
				}
				uni.navigateTo({
					url:"/pages/workbench/gongzuot?msg=" + encodeURIComponent(JSON.stringify(data))
				})
			},
			uploadImgtop(upImgs, upImgs_arr, value) {
				let _this = this;
				let num = Number(value) - upImgs.length;
				if (num <= 0) {
					return false;
				}
				uni.showActionSheet({
					itemList: ['相機', '相簿'],
					success: function(res) {
						// 選擇相機走0
						if (res.tapIndex == 0) {
							httpRequest.chooseImage(num, ['camera']).then(res => {
								for (var i = 0; i < res.length; i++) {
									_this.uploadImageService(res[i], upImgs, upImgs_arr)
								}
							}).catch(err => {});
						}
						// 選擇相簿走1
						if (res.tapIndex == 1) {
							httpRequest.chooseImage(num, ['album']).then(res => {
								for (var i = 0; i < res.length; i++) {
									_this.uploadImageService(res[i], upImgs, upImgs_arr)
								}
							}).catch(err => {});
						}
					},
					fail: function(res) {}
				});
			},
			uploadImageService(url, upImg, upImgs_arr) {
				let _this = this;
				httpRequest.uploadFile('/api/common/upload', url).then(res => {
					upImg.push(res.url)
					let image_item = res.fullurl;
					upImgs_arr.push(image_item);
					if (this.carouselimages.length < 10) {
						this.carouselimages.push(res.url)
						this.carouselimages_arr.push(image_item)
					}

				}).catch(err => {});
			},
			addby() {
				if (this.by_text == "") {
					return false
				}
				this.sp_attr.push(this.by_text)
				this.by_text = ""
			},
			getshopDetail() {
				this.http.request("/api/shop/Shopdeail", 'POST', {
					shop_id: uni.getStorageSync("shop_id")
				}).then(res => {
					this.shopInfo = res.data
				})
			},
			saoma() {
				uni.navigateTo({
					url: "/pages/workbench/scanywcode"
				})
			},
			async getGoodsInfo() { //商品详情
				let _this = this
				let res = await this.http.request('/api/goods/deailGoods', 'POST', {
					id: this.goodsId
				})
				if (res.code == 1) {
					this.isdetail = 1
					this.name = res.data.name
					if (res.data.logoimage) {
						this.logoimage.push(res.data.logoimage)
						let imageuer = this.imgUrlUser + res.data.logoimage
						this.logoimage_arr.push(imageuer)
					}
					if (res.data.carouselimages) {
						let imagesurl = []
						res.data.carouselimages.split(',').forEach(item => {
							this.carouselimages.push(item)
							let imageuer = this.imgUrlUser + item
							imagesurl.push(imageuer)
						})
						this.carouselimages_arr = imagesurl
					}
					if (res.data.detailsimages) {
						let imagesurl = []
						res.data.detailsimages.split(',').forEach(item => {
							this.detailsimages.push(item)
							let imageuer = this.imgUrlUser + item
							imagesurl.push(imageuer)
						})
						this.detailsimages_arr = imagesurl
					}
					this.mvfile = res.data.mvfile
					this.mvfile_arr = res.data.mvfile ? this.imgUrlUser + res.data.mvfile : ''
					//销售类别
					if (res.data.goods_sale.length) {
						this.saleList = res.data.goods_sale
						this.saleList.forEach(item => {
							this.$set(item, "morepice", [])
							this.$set(item, "jsval", "")
							this.$set(item, "moremoney", "")
							item.sale_money.forEach(ite => {
								item.morepice.push({
									val: ite.js_num,
									money: ite.d_money
								})
							})
							this.saleId.push(item.id)
						})
					}
					let arr2 = []
					res.data.spu_data_text.forEach(item => {
						let goods_spunat = []
						item.spu_item.forEach(cur => {
							goods_spunat.push({
								image_arr: [cur.image_text],
								images: [cur.image],
								money: cur.money,
								name: cur.name,
								yg_money:cur.yg_money
							})
						})
						arr2.push({
							arrtName: "",
							attrId: [],
							fh: item.fh,
							id: "",
							name: item.name,
							num_b: item.num_b,
							goods_spunat,
							ygfh: item.ygfh,
							font_color:item.font_color,
							ygnum_b: item.ygnum_b
						})
					})
					this.spu_data = arr2
					this.day = res.data.day
					this.sp_attr = res.data.sp_attr ? res.data.sp_attr.split(',') : []
					this.num = res.data.num
					this.cai = res.data.cai
					this.des = res.data.des
					this.font_color = res.data.font_color
					this.size = res.data.size ? res.data.size.split(';') : []
					this.unit = res.data.unit
					this.jj_unit = res.data.unit
					this.weight = res.data.weight
					this.caiamass = res.data.caiamass
					this.shopformula_id = res.data.shopformula_id
					this.shopformula_name = res.data.shopformula?.name
					this.shopwork_id = res.data.shopwork_id
					this.shopwork_name = res.data.shopwork?.name
					if (res.data.goods_sku.length) {
						res.data.goods_sku.forEach(item => {
							this.sku_id.push(item.id)
						})
					}
					if (res.data.goods_spu.length) {
						res.data.goods_spu.forEach(item => {
							this.spu_id.push(item.id)
						})
					}
					this.price = res.data.price
					if (Number(this.price)) {
						this.jjfs = 0
					} else {
						this.jjfs = 1
					}
					this.cdbtc_ids = res.data.cdbtc_ids
					this.firm_id = res.data.firm_id
					this.phone = res.data.phone
					this.barcode = res.data.barcode
					this.is_up = res.data.is_up.toString()
					this.rj_type = res.data.rj_type
					this.is_cl = res.data.is_cl
					this.is_grounding = res.data.is_grounding.toString()
					this.is_main = res.data.is_main.toString()
					this.is_size = res.data.is_size
					this.is_sizeFlag = this.is_size == 1 ? true : false
					this.weight_jj_status = res.data.weight_jj_status
					this.weight_jj_statusFlag = this.weight_jj_status == 1 ? true : false

					this.date = res.data.date
					this.datedeail = res.data.datedeail ? res.data.datedeail.split(',') : []
					this.end_num = res.data.end_num || ""
					this.xd_num = res.data.xd_num || ""
					this.notice = res.data.notice
					this.buy_notice = res.data.buy_notice

					this.goodsInfo = res.data
				} else if (res.code == 0) {
					// this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			pushmore(item) {
				if (item.jsval == "") {
					this.http.toast("請輸入計算值")
					return false
				}
				if (item.moremoney == "") {
					this.http.toast("請輸入單價")
					return false
				}
				item.morepice.push({
					money: item.moremoney,
					val: item.jsval
				})
				item.moremoney = ""
				item.jsval = ""
			},
			selectRule(url) {
				uni.navigateTo({
					url
				})
			},
			selectRuledate(url) {
				let data = {
					datedeail: this.datedeail,
					date: this.date
				}
				uni.navigateTo({
					url: url + "?msg=" + encodeURIComponent(JSON.stringify(data))
				})
			},
			upvideo() { //上传影片
				let uploadFile = ''
				let _this = this;
				// 1.選擇要上传的影片
				uni.chooseVideo({
					maxDuration: 60, // 拍摄影片最长拍摄時間，單位秒。最长支持 60 秒。
					sourceType: ['album', 'camera'], // album 从相簿选影片，camera 使用相機拍摄，默认为：['album', 'camera']
					success: function(res) {
						_this.uploadImageServicet(res.tempFilePath)
					}
				});
			},
			delevideo() {
				this.mvfile = ""
				this.mvfile_arr = ""
			},
			uploadImageServicet(url) {
				let _this = this;
				this.http.uploadFile('/api/common/upload', url).then(res => {
					let image_item = res.fullurl;
					this.mvfile = res.url
					this.mvfile_arr = image_item
				}).catch(err => {});
			},
			deleimage(i, upimg, arr) { //刪除图片
				upimg.splice(i, 1)
				arr.splice(i, 1)
			},
			addSize() {
				if (this.size_text == "") {
					return false
				}
				this.size.push(this.size_text)
				this.size_text = ""
			},
			addSale() { //添加销售类别
				this.saleList.push({
					id: "", //销售类别id
					name: "", //名称
					jsval: "",
					moremoney: "",
					morepice: [],
					price_j: "", //基本价
				})
			},
			delSale(item, index) { //刪除销售类别
				this.saleList.splice(index, 1)
				if (item.id) {
					this.getDelSale(item.id)
				} else {
					this.http.toast("刪除成功！")
				}
			},
			async getDelSale(id) {
				let res = await this.http.request("/api/goods/delSale", 'POST', {
					id
				})
				if (res.code == 1) {
					this.http.toast("刪除成功！")
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			weightjjstatusFlagchange(e) { //重量計價開關
				this.weight_jj_status = e ? 1 : 0
			},
			sizeFlagchange(e) { //尺寸开关
				this.is_size = e ? 1 : 0
			},
			confirm() { //確認

				if (this.saleList.length == 0 && this.price == "") {
					this.http.toast('請輸入商品價格');
					return false
				}
				if (this.saleList.length) {
					for (let i = 0; i < this.saleList.length; i++) {
						let current = this.saleList[i]
						if (current.morepice.length == 0) {
							this.http.toast("銷售類別" + current.name + "的多重單價信息至少添加一個")
							return false
						}
					}
					this.saleList.forEach((item, index) => {
						this.submitSale(item.id, item.name, item.morepice, item.price_j, index)
					})
				} else {
					this.submit()
				}

			},
			async submitSale(id, name, morepice, price_j, index) { //添加销售类别
				let res = await this.http.request("/api/goods/addSale", 'POST', {
					id, //销售类别id
					name, //名称
					// price, //單价
					price_j, //基本价
				})
				if (res.code == 1) {
					if (res.data !== 1) {
						this.saleId.push(Number(res.data))
						let resp = await this.http.request("/api/goods/addsalempney", 'POST', {
							sale_id: res.data, //销售类别id
							morepice
						})
					} else {
						let resp = await this.http.request("/api/goods/addsalempney", 'POST', {
							sale_id: id, //销售类别id
							morepice
						})
					}
					if (index == this.saleList.length - 1) {
						this.submit()
					}
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			async submit() { //编辑商品提交
				let _this = this
				// if (!this.firm_id && !this.phone) {
				// 	this.http.toast("請输入廠商电话！")
				// 	return false
				// }

				if (this.saleList.length == 0 && this.price == "") {
					this.http.toast("請輸入商品價格")
					return false
				}
				// if(this.shopwork_id==""){
				// 	this.http.toast("請選擇工作站")
				// 	return false
				// }
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				let data = []
				this.spu_data.forEach(item => {
					let spu_item = []
					item.goods_spunat.forEach(cur => {
						spu_item.push({
							name: cur.name,
							money: cur.money,
							image: cur.images[0] || "",
							yg_money:cur.yg_money
						})
					})
					data.push({
						name: item.name,
						num_b: item.num_b,
						fh: item.fh,
						spu_item,
						ygfh: item.ygfh,
						font_color:item.font_color,
						ygnum_b: item.ygnum_b
					})
				})
				let res = await this.http.request("/api/goods/editGoods", 'POST', {
					id: this.goodsId, //商品id
					shop_id: this.shop_id,
					name: this.name, //商品名称
					logoimage: this.logoimage.join(), //商品主图
					carouselimages: this.carouselimages.join(), //商品轮播图
					detailsimages: this.detailsimages.join(), //商品详情图

					mvfile: this.mvfile, //商品影片

					goods_sale_id: this.saleId.join(), //销售类别id
					day: this.day, //交货天数
					sp_attr: this.sp_attr.join(),
					num: this.num, //基本数量
					cai: this.cai, //基本用量
					des: this.des,
					font_color:this.font_color,
					size: this.size.join(';'), //基本尺寸
					unit: this.unit, //單位
					jj_unit: this.unit,
					weight: this.weight, //重量
					caiamass: this.caiamass, //才积

					shopformula_id: this.shopformula_id, //公式ID
					shopwork_id: this.shopwork_id, //工作站ID
					spu_id: this.spu_id.join(), //商品规格1 id
					// sku_id: this.sku_id.join(), //商品规格2 id
					cdbtc_ids: this.cdbtc_ids,
					is_cl: this.is_cl,
					price: this.price, //价格
					firm_id: this.firm_id, //廠商ID
					phone: this.phone, //廠商电话
					barcode: this.barcode, //条形碼
					is_up: this.is_up, //档案是否上传:0=否,1=是
					rj_type: this.rj_type,
					is_grounding: this.is_grounding, //是否上架:0=否,1=是,	
					is_main: this.is_main,
					date: this.date, //上架時間
					datedeail: this.datedeail.join(),
					// enddate: this.enddate, //下架時間
					is_size: this.is_size, //尺寸开关:0=否,1=是
					weight_jj_status: this.weight_jj_status,
					end_num: this.end_num == "" ? -1 : this.end_num, //库存
					xd_num: this.xd_num == "" ? -1 : this.xd_num, //限點數量
					notice: this.notice, //出货須知
					buy_notice: this.buy_notice, //購買須知
					// count: this.count, //销量
				})
				uni.hideLoading()
				if (res.code == 1) {
					this.http.toast("修改成功")
					setTimeout(() => {
						uni.navigateBack(1)
					}, 500)
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.lineorange {
		height: 30rpx;
		width: 100%;
		background-color: #ffb800;
	}

	::v-deep.u-radio-group {
		flex: none !important;
	}

	.borderhui {
		background-color: #fff;
		border-radius: 10rpx;
		// padding: 35rpx;
		box-sizing: border-box;
		margin-right: 30rpx;
		text-align: center;
	}
</style>